package com.ruoyi.job.task;

import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.CommonEntity;
import com.ruoyi.job.remoteService.HualalaRemoteService;
import com.ruoyi.job.remoteService.KingdeeRemoteSevice;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component("kingdeeTask")
public class KingdeeTask {
    @Resource
    public KingdeeRemoteSevice kingdeeRemoteService;

    /**
     * 得到集团下面所有的公司（含有门店）
     * @param approveDate
     */
    public void saveAllOrg(String approveDate)
    {
        kingdeeRemoteService.saveAllOrg(approveDate);
    }

    /**
     * 得到门店下面所有的部门
     * pfnumber这个是金蝶的门店编码
     * @param approveDate
     * @param pfnumber
     */
    public void saveShopDept(String approveDate,String pfnumber)
    {
        CommonEntity entity=new CommonEntity();
        entity.setApproveDate(approveDate);
        entity.setPfnumber(pfnumber);
        kingdeeRemoteService.saveShopDept(entity);
    }


    public void saveMaterialTransUnit(String approveDate)
    {
        kingdeeRemoteService.saveMaterialTransUnit(approveDate);
    }

    public void saveAllEmp(String approveDate)
    {
        kingdeeRemoteService.saveAllEmp(approveDate);
    }



    public void saveCurrentDateMaterialPurchase(String approveDate){
        if(StringUtils.isEmpty(approveDate))
            approveDate=getCurrentDate();
        kingdeeRemoteService.saveMaterialPurchase(approveDate);
    }



    public void saveMaterialTransferin(String approveDate){
        if(StringUtils.isEmpty(approveDate))
            approveDate=getCurrentDate();
        kingdeeRemoteService.saveMaterialTransferin(approveDate);
    }


    public void    saveMaterialTransferout(String approveDate) throws ParseException {
        if(StringUtils.isEmpty(approveDate))
            approveDate=getCurrentDate();
        kingdeeRemoteService.saveMaterialTransferout(approveDate);
    }

    public void   saveMaterialIncase(String approveDate){
        if(StringUtils.isEmpty(approveDate))
            approveDate=getCurrentDate();
        kingdeeRemoteService.saveMaterialIncase(approveDate);
    }
    String getCurrentDate(){
    // 获取当前日期
    Date currentDate = new Date();

    // 定义日期格式化器
    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

    // 将日期格式化为字符串
    String formattedDate = formatter.format(currentDate);
    return formattedDate;
}


}
